/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-06-18 15:41:49
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Examinations.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const Examinations = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'tableName@desc,code@asc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.code, rules: true },
            {
                dataIndex: 'tableName',
                title: '年月',
                valueType: 'Date',
                picker: 'month',
                rules: true,
                width: 100,
                hideInSearch: true,
            },
            {
                dataIndex: 'tableName',
                title: '年月',
                valueType: 'dateMonth',
                width: 100,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            {
                dataIndex: 'fullName',
                title: '题干',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'questionType',
                title: '类型',
                valueType: 'select',
                valueEnum: BuiltInData.questionType,
                ellipsis: true,
                rules: true,
                width: 100,
                hideInSearch: true,
            },
            {
                dataIndex: 'remark',
                title: '答案',
                rules: true,
                valueType: 'input',
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'score',
                title: '分值',
                rules: true,
                valueType: 'inputNumber',
                width: 100,
                hideInSearch: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoOne"
                            title="问题选项"
                            twoTitle="项目信息固定数据"
                            modal="EditTableModal"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'Examinations',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
